package com.mybook.app.controller;

import com.mybook.app.conf.WxConfig;
import com.mybook.app.core.BaseResponse;
import com.mybook.app.feign.MinaFeignClient;
import com.mybook.app.request.WxLoginRequest;
import com.mybook.app.response.MinaAccessTokenResponse;
import com.mybook.app.response.WxLoginResponse;
import com.mybook.app.service.MinaService;
import com.mybook.app.utils.JsonUtil;
import com.mybook.app.utils.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cloud.netflix.feign.EnableFeignClients;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 微信小程序接口
 */
@RestController
@RequestMapping(value = "/mina")
public class MinaController {

    @Autowired
    private MinaService minaService;


    /**
     * 微信小程序登录接口
     * APPID：wxa641c599fa36c53e  APPsecret：29a06ef261d7c094922c941616748e14
     *
     * @param
     * @return
     */
    @PostMapping(value = "/onLogin")
    public BaseResponse onLogin(@RequestBody WxLoginRequest wxLoginRequest) {
        Logger.info(this, "进入接口：微信小程序登录  >  code:" + wxLoginRequest);
        WxLoginResponse wxLoginResponse = minaService.onLogin(wxLoginRequest);
        return new BaseResponse(wxLoginResponse);

    }


}
